package com.ssy.lingxi.purchase.job;

import com.ssy.lingxi.purchase.service.purchaseplan.PurchasePlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 采购计划 - 定时器
 * @author fhj
 * @version 2.0.0
 * @date 2021/03/04
 */
@Slf4j
@Component
public class PurchasePlanScheduler {

    @Resource
    private PurchasePlanService purchasePlanService;


    @Async
    @Scheduled(cron = "0 0 1 * * ?") //每天凌晨1点执行一次
    //@Scheduled(cron = "0 */1 * * * ?") //每隔1分钟执行一次
    public void scheduledTask() {
        try {
            purchasePlanService.execute();
        } catch (Exception e) {
            log.error("自动执行采购计划失败", e);
            e.printStackTrace();
        }
    }
}
